/**
 * Created by z on 2017/5/18.
 */

/*获取账户信息*/
$(function () {
    var userId = '07e131b2652149ae89e647b3ccd89524';
    $.ajax({
        type:"post",
        url:config.devUrl+"/account/quaryAccount.json",
        data:{'userId':userId},
        dataType:"json",
        success:function(data){
            var html = template('trans-account-temp',data);
            $("#trans-account").html(html);
        }
    });
});

/*转账*/
function transAccount(){
    var accountId = $("#accountId").val();
    if(accountId==undefined || accountId ==null ||accountId==''){
        alert("账户不能为空");
        return false;
    }
    var phoneNum = $("#mobile").val();
    if(phoneNum==undefined || phoneNum ==null ||phoneNum==''){
        alert("手机号不能为空");
        return false;
    }
    var amount = parseInt($("#amount").val());
    if(amount==undefined || amount ==null ||amount==''){
        alert("金额不能为空");
        return false;
    }
    if(amount<=0){
        alert("金额不能小于0");
        return false;
    }

    var param = {};
    param.amount = amount;
    param.phoneNum = phoneNum;
    param.accountId = accountId;

    $.ajax({
        type:"post",
        url:config.devUrl+"/account/transferOfAccount.json",
        data:param,
        dataType:"json",
        success:function(data){
            if(data.data.status=='999'){
                alert(data.data.msg);
            }
            if(data.data.status=='0'){
                alert("转账成功");
            }
        }
    });
}
